﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace JTicket.UI
{
    public partial class S_Return : System.Web.UI.Page
    {
        private readonly BLL.D_OperInfo bllOper = new BLL.D_OperInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
                Bind();
        }
        protected void ImageButton1_Command(object sender, EventArgs e)
        {
            string BarCode = dg1.Items[0].Cells[0].Text;
            string TitleCode = dg1.Items[0].Cells[1].Text;
            if (DAL.H_Return.GetStatus(BarCode, TitleCode))
            {

                string Area = dg1.Items[0].Cells[4].Text;
                string Row = dg1.Items[0].Cells[6].Text;
                string Cow = dg1.Items[0].Cells[7].Text;
                string Note = dg1.Items[0].Cells[5].Text;
                string sixid = dg1.Items[0].Cells[8].Text;
                string TicketName = dg1.Items[0].Cells[9].Text;
                string OperCode = bllOper.Oper().OperCode;
                string Model = "退票";
                bool b = false;
                b = DAL.H_TicketBal.ReturnTicket
                       (BarCode, TitleCode, Area, Row, Cow, Note, TicketName, OperCode, Model);
                if (b)
                {
                    Common.JsMsg.MsgBoxRedrect("退票申请操作成功!", "S_Return.aspx", this.Page);
                    Bind();
                }
                else
                    Common.JsMsg.Alert("退票操作失败，请重新操作！");
            }
            else
                Common.JsMsg.Alert("此票审核中。。。！");
        }
        protected void dg1_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemIndex == -1) return;
            e.Item.Attributes.Add("bgcolor", "#EFFFDA");
            e.Item.Attributes.Add("style", "cursor:hand");
            e.Item.Attributes.Add("onMouseOver=this.style.backgroundColor", "#DBE3FA");
            e.Item.Attributes.Add("onMouseOut=this.style.backgroundColor", "#F6F6F6");

        }
        void Bind()
        {
            string opercode = bllOper.Oper().OperCode;
            List<Model.H_Return> list = DAL.H_Return.GetList(opercode);
            this.dg1.DataSource = list;
            this.dg1.DataBind();
        }

        public string state(string st)
        {
            switch (st)
            {
                case "1":
                    return "审核中";
                case "2":
                    return " 退 票";
                default:
                    return "审核中";
            }
        } 
    }
}